<?php
class Grupo extends AppModel {
	var $name = 'Grupo';
	var $useTable = 'grupos';
	var $validate = array(
		'id' => array(
			'blank' => array(
				'rule' => array('blank'),
				'on' => 'create' 
			)
		),
		'curso_id' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty')
			),
			'numeric' => array(
				'rule' => array('numeric')
			)
		),
		'hora_id' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty')
			),
			'numeric' => array(
				'rule' => array('numeric')
			)
		),
		'dia_id' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty')
			),
			'numeric' => array(
				'rule' => array('numeric')
			)
		),
		'fechaini' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty')
			)
		),
		'comentario' => array(
			'maxlength' => array(
				'rule' => array('maxLength', '255')
			)
		),
		'tentativo' => array(
			'boolean' => array(
				'rule' => array('boolean')
			),
			'notEmpty' => array(
				'rule' => array('notEmpty')
			)
		),
		'incompany' => array(
			'boolean' => array(
				'rule' => array('boolean')
			),
			'notEmpty' => array(
				'rule' => array('notEmpty')
			)
		),
		'personalizado' => array(
			'boolean' => array(
				'rule' => array('boolean')
			),
			'notEmpty' => array(
				'rule' => array('notEmpty')
			)
		),
		'usuario_id' => array(
			'notEmpty' => array(
				'rule' => array('notEmpty')
			),
			'numeric' => array(
				'rule' => array('numeric')
			)
		)
	);

	var $belongsTo = array(
		'Curso' => array(
			'className' => 'Curso',
			'foreignKey' => 'curso_id'
		),
		'Dia' => array(
			'className' => 'Dia',
			'foreignKey' => 'dia_id'
		),
		'Hora' => array(
			'className' => 'Hora',
			'foreignKey' => 'hora_id'
		),		
		'Usuario' => array(
			'className' => 'Persona',
			'foreignKey' => 'usuario_id'
		)
	);

	var $hasMany = array(
		'Clase' => array(
			'className' => 'Clase',
			'foreignKey' => 'grupo_id'
		),
		'FacturaCurso' => array(
			'className' => 'FacturaCurso',
			'foreignKey' => 'grupo_id'
		),
		'Encuesta' => array(
			'className' => 'Encuesta',
			'foreignKey' => 'grupo_id'
		),		
		'ReciboGastoCurso' => array(
			'className' => 'ReciboGastoCurso',
			'foreignKey' => 'grupo_id'
		),
		'ReciboVentaCurso' => array(
			'className' => 'ReciboVentaCurso',
			'foreignKey' => 'grupo_id'
		),
		'SolicitudEspera' => array(
			'className' => 'SolicitudEspera',
			'foreignKey' => 'grupo_id'
		),
		'SolicitudEvento' => array(
			'className' => 'SolicitudEvento',
			'foreignKey' => 'grupo_id'
		)
	);

	var $hasAndBelongsToMany = array(
		'Persona' => array(
			'className' => 'Persona',
			'joinTable' => 'grupos_personas',
			'foreignKey' => 'grupo_id',
			'associationForeignKey' => 'persona_id',
			'unique' => true
		)
	);
}
?>